<!doctype html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>京东注册页面</title>
    <link href="css/leisure.css" rel="stylesheet">
</head>

<body>
    <div id="header" class="main">
        <div id="headerLeft">
            <img src="images/JDicon.png" />
        </div>
        <div id="headerRight">注册 | 登录 | 帮助</div>
    </div>
    <div class="register">
        <form method="post" name="myform" id="myform">
            <h1 class="bold">注册京东会员</h1>
            <dl>
                <dt>您的Email：</dt>
                <dd><input id="email" type="text" class="inputs" /><span id="DivEmail"></span></dd>
            </dl>
            <dl>
                <dt>您的手机号：</dt>
                <dd><input id="tel" type="text" class="inputs" /><span id="DivTel"></span></dd>
            </dl>
            <dl>
                <dt>输入密码：</dt>
                <dd><input id="pwd" type="password" class="inputs" /><span id="DivPwd"></span></dd>
            </dl>
            <dl>
                <dt>再输入一遍密码：</dt>
                <dd><input id="repwd" type="password" class="inputs" /><span id="DivRepwd"></span></dd>
            </dl>

            <dl>
                <dt>&nbsp;</dt>
                <dd><input id="btn" name="btn" type="button" value="登录" class="rb1" /></dd>
            </dl>
        </form>
    </div>
    <div id="footer" class="main"><a href="#">关于我们</a> | <a href="#">诚聘英才</a> |<a href="#"> 联系方式</a> | <a
            href="#">帮助中心</a></div>
    <!-- text -->
    <script src="js/jquery-1.12.4.js"></script>
    <script>
        $(document).ready(function () {
            // $("#myform").submit(function(){

            //     let pwd = $("#pwd").val();
            //     // let url = ;


            //     $.post("http://39.103.160.49:8888/user/register?username="+user+"&password="+pwd,function(data){
            //         console.log(data);                 
            //         alert(data.message);
            //     },true)
            //     return true;
            // })
            $("#email1").blur(function () {
                $.post("http://39.103.160.49:8888/user/register?username=" + $("#email").val() + "&password=111111", function (data) {
                    if (data.status == 200) {
                        $("#DivEmail").html("<span style='color:green'>正确</span>")
                    } else {
                        $("#DivEmail").html(data.message)
                    }
                })
            })
            $("#btn").click(function(){
                let tel = $("#tel").val();
                let pwd = $("#pwd").val();
                console.log(tel+":"+pwd);
                $.ajax({
                    url:'http://39.103.160.49:8888/user/login',
                    type:"POST",
                    contentType:'application/json',
                    data:JSON.stringify({
                        username:tel,
                        password:pwd
                    }),
                    success:function(data){
                        console.log(data.message);                        
                    },
                    error:function(){
                    }
                })
                
            })
        })

    </script>

</body>

</html>